Image capturing apparatus and control method therefor

ABSTRACT

An image capturing apparatus comprising: an image sensor configured to perform photoelectric conversion on light that enters via an imaging optical system and output an image signal; a focus detection unit configured to detect an in-focus position based on the image signal output from the image sensor; an edge detection unit configured to detect an edge angle and a number of edge of a subject included in an image based on the image signal output from the image sensor; and a correction unit configured to obtain a correction amount for the in-focus position based on the detected edge angle and the number of edge and correct the in-focus position detected by the focus detection unit based on the obtained correction amount.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to an image capturing apparatus and acontrol method therefor, and more specifically, to an image capturingapparatus having autofocus function and a control method therefor.

2. Description of the Related Art

Typical schemes of focus control methods for image capturing apparatusesinclude a contrast AF scheme and a phase difference AF scheme. Thecontrast AF scheme and the phase difference AF scheme are AF schemeswidely used in video cameras and digital still cameras, with an imagesensor being used as a focus detection sensor.

In these focus control methods, focus detection results may containerrors due to various aberrations of an optical system. Various methodshave been proposed to reduce such errors. Japanese Patent Laid-Open No.2007-94236 discloses a method in which frequency components areextracted from a signal for focus detection in the two directions thatare orthogonal to each other and corrected, and focus detection isperformed based on an added output of the corrected frequencycomponents.

Such focus detection error occurs depending on the arrangement directionof pixels on the image sensor that output signals to be used for focuscontrol in the contrast AF method and the phase difference AF methodregardless of the focus control methods in a case where an imagecapturing apparatus using an optical system that has astigmatism, forexample.

However, in the configuration disclosed in Japanese Patent Laid-Open No.2007-94236, there is a problem in which a focus detection error cannotbe sufficiently corrected as will be explained below. Firstly, accordingto Japanese Patent Laid-Open No. 2007-94236, in order to reduce thefocus detection error, the focus detection is performed by setting theevaluation directions of the signals for focus control to the horizontaland vertical directions, and weighing the focus detection resultsdetected in the respective evaluation directions. On the other hand, thefocus detection error is decided by an angle of an edge of a subject,not by the evaluation direction. For example, if 45° is only an existingedge angle of the subject, a focus detection error is the same for theevaluation in the horizontal direction and for the evaluation in thevertical direction. However, Japanese Patent Laid-Open No. 2007-94236 issilent about a method for correcting the focus detection error inaccordance with the edge angle of the subject.

SUMMARY OF THE INVENTION

The present invention has been made in consideration of the abovesituation, and properly corrects a focus detection error that occurs dueto an edge angle of a subject upon performing a focus detection.

According to the present invention, provided is an image capturingapparatus comprising: an image sensor configured to performphotoelectric conversion on light that enters via an imaging opticalsystem and output an image signal; a focus detection unit configured todetect an in-focus position based on the image signal output from theimage sensor; an edge detection unit configured to detect an edge angleand a number of edge of a subject included in an image based on theimage signal output from the image sensor; and a correction unitconfigured to obtain a correction amount for the in-focus position basedon the detected edge angle and the number of edge and correct thein-focus position detected by the focus detection unit based on theobtained correction amount.

According to the present invention, provided is a control method of animage capturing apparatus comprising: performing photoelectricconversion on light that enters via an imaging optical system andoutputting an image signal; detecting an in-focus position based on theoutput image signal; detecting an edge angle and a number of edge of asubject included in an image based on the output image signal; andobtaining a correction amount for the in-focus position based on thedetected edge angle and the number of edge and correcting the in-focusposition based on the obtained correction amount.

Further features of the present invention will become apparent from thefollowing description of exemplary embodiments (with reference to theattached drawings).

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute apart of the specification, illustrate embodiments of the invention, andtogether with the description, serve to explain the principles of theinvention.

FIG. 1 is a block diagram schematically showing the structure of adigital camera according to an embodiment of the present invention;

FIG. 2 is a plan view of light receiving pixels as seen from the lensunit side according to the embodiment;

FIG. 3 is a diagram schematically showing the structure of an imagesensor including a read circuit according to the embodiment;

FIGS. 4A and 4B are diagrams for describing the conjugate relationbetween an exit pupil plane of an imaging optical system andphotoelectric converters of a pixel located around the center of animaging plane according to the embodiment;

FIG. 5 is a block diagram mainly showing the structure of a TV-AF focusdetector according to the embodiment;

FIG. 6 is a diagram showing an example of focus detection areasaccording to the embodiment;

FIGS. 7A and 7B are flowcharts showing an AF processing procedureaccording to the embodiment;

FIG. 8 is a diagram showing an example of BP correction informationaccording to the embodiment;

FIG. 9 is a diagram illustrating an edge angle of a subject according tothe embodiment;

FIG. 10 is a diagram for explaining a method for calculating thedirection of a slope at the coordinates of each pixel position accordingto the embodiment;

FIG. 11 is a diagram for explaining a method for obtaining an edge angleof a focus detection area; and

FIGS. 12A and 12B show examples of edges and contrasts of a subjectaccording to the embodiment.

DESCRIPTION OF THE EMBODIMENTS

Exemplary embodiments of the present invention will be described indetail in accordance with the accompanying drawings. An embodimentdescribes an example of applying the present invention to a single-lensreflex digital camera for which a lens is interchangeable.

Description of Structure of Image Capturing Apparatus

FIG. 1 is a block diagram schematically showing the structure of thedigital camera according to the embodiment. As mentioned above, thedigital camera in the embodiment is an interchangeable lens typesingle-lens reflex camera, and includes a lens unit 100 and a camerabody 120. The lens unit 100 is connected to the camera body 120 via amount M indicated by the dotted line in the center of the drawing.

The lens unit 100 includes a first lens group 101, an aperture-shutter102, a second lens group 103, a focus lens group (hereafter simplyreferred to as a “focus lens”) 104, and a drive/control system. The lensunit 100 thus includes the focus lens 104 and the imaging lens unit forforming an image of a subject.

The first lens group 101 is located at the front end of the lens unit100, and held to be movable forward and backward in an optical axisdirection OA. The aperture-shutter 102 adjusts its aperture diameter toadjust the amount of light when capturing an image, and also functionsas a shutter for exposure time adjustment when capturing a still image.The aperture-shutter 102 and the second lens group 103 integrally moveforward and backward in the optical axis direction OA, to realize a zoomfunction together with the forward and backward movement of the firstlens group 101. The focus lens 104 is also moved forward and backward inthe optical axis direction OA to perform focus control.

The drive/control system includes a zoom actuator 111, anaperture-shutter actuator 112, a focus actuator 113, a zoom drivecircuit 114, an aperture-shutter drive circuit 115, a focus drivecircuit 116, a lens MPU 117, and a lens memory 118.

The zoom drive circuit 114, according to a zoom operation by aphotographer, drives the zoom actuator 111 to drive the first lens group101 and the second lens group 103 forward and backward in the opticalaxis direction OA, thus performing the zoom operation. Theaperture-shutter drive circuit 115 drives/controls the aperture-shutteractuator 112 to control the aperture diameter of the aperture-shutter102, thus adjusting the amount of light during image capturing and alsocontrolling the exposure time during still image capturing. The focusdrive circuit 116, based on a focus detection result, drives/controlsthe focus actuator 113 to drive the focus lens 104 forward and backwardin the optical axis direction OA, thus performing focus control. Thefocus actuator 113 has a function of a position detector for detectingthe current position of the focus lens 104.

The lens MPU 117 performs all computation and control relating to thelens unit 100, and controls the zoom drive circuit 114, theaperture-shutter drive circuit 115, the focus drive circuit 116, and thelens memory 118. The lens MPU 117 detects the current lens position, andprovides lens position information in response to a request from acamera MPU 125. The lens position information includes information aboutthe optical axial position of the focus lens 104, the optical axialposition and diameter of an exit pupil in a state where an imagingoptical system is not moving, and the optical axial position anddiameter of a lens frame that limits the light flux of the exit pupil.The lens memory 118 stores optical information necessary for auto focuscontrol.

The camera body 120 includes an optical low-pass filter (LPF) 121, animage sensor 122, and a drive/control system. The optical LPF 121 andthe image sensor 122 function as an image sensing optical system forforming a subject image with a light beam from the lens unit 100. Thefirst lens group 101, the aperture-shutter 102, the second lens group103, the focus lens 104, and the optical LPF 121 constitute theabove-mentioned imaging optical system.

The optical LPF 121 reduces false color and moire in a captured image.The image sensor 122 is composed of a CMOS sensor and its peripheralcircuitry, and has m pixels in the horizontal direction and n pixels inthe vertical direction. The image sensor 122 includes pixels havingphotoelectric converters of the structure described later with referenceto FIG. 2, and can output a pair of signals for performing thebelow-mentioned focus detection of the phase difference scheme (phasedifference AF). Of the obtained signals, those to be used for phasedifference AF are converted to focus detection image data by an imageprocessing circuit 124. In addition, of the obtained signals, those tobe used for display, recording, or focus detection of the contrastscheme are also transmitted to the image processing circuit 124 andsubjected to predetermined processes depending on purpose.

The drive/control system includes an image sensor drive circuit 123, theimage processing circuit 124, the camera MPU 125, a display 126, anoperation switch group 127, a memory 128, an on-imaging surface phasedifference focus detector 129, and a TV-AF focus detector 130.

The image sensor drive circuit 123 controls the operation of the imagesensor 122, and also performs A/D conversion on an obtained image signaland transmits the converted image signal to the camera MPU 125 and theimage processing circuit 124. The image processing circuit 124 performsconversion, color interpolation, JPEG compression, etc. on the imagesignal obtained by the image sensor 122.

The camera MPU (processor) 125 performs all computation and controlrelating to the camera body 120, and controls the image sensor drivecircuit 123, the image processing circuit 124, the display 126, theoperation SW group 127, the memory 128, the on-imaging surface phasedifference focus detector 129, and the TV-AF focus detector 130. Thecamera MPU 125 is connected to the lens MPU 117 via a signal line of themount M, and issues, to the lens MPU 117, a request to obtain the lensposition or a request to drive the lens by a predetermined drive amount,or obtain optical information unique to the lens unit 100. The cameraMPU 125 includes a ROM 125 a storing a program for controlling cameraoperation, a RAM 125 b storing variables, and an EEPROM 125 c storingvarious parameters.

The display 126 includes an LCD or the like, and displays informationabout the imaging mode of the camera, a preview image before imageshooting and a confirmation image after image shooting, an in-focusstate indication image upon focus detection, and the like. The operationswitch group 127 includes a power switch, a release (imaging trigger)switch, a zoom operation switch, and an imaging mode selection switch.The memory 128 is a removable memory such as flash memory, and recordscaptured images.

The on-imaging surface phase difference focus detector 129 performs thefocus detection process of the phase difference scheme (on-imagingsurface phase difference AF) using the focus detection image dataobtained by the image sensor 122 and the image processing circuit 124.In more detail, the on-imaging surface phase difference focus detector129 performs on-imaging surface phase difference AF based on thedeviation of a pair of images formed in focus detection pixels by alight beam passing through a pair of pupil areas of the imaging opticalsystem. The method of on-imaging surface phase difference AF will bedescribed in detail later.

The TV-AF focus detector 130 calculates various TV-AF evaluation valuesusing contrast components of image information obtained by the imageprocessing circuit 124, and performs the focus detection process of thecontrast scheme (TV-AF). In the focus detection process of the contrastscheme, focus evaluation values at a plurality of focus lens positionsare calculated while moving the focus lens 104, and a focus lensposition corresponding to a peak focus evaluation value is detected.

Thus, in the embodiment, on-imaging surface phase difference AF andTV-AF are both adopted, and can be used selectively or in combinationdepending on situation. The camera MPU 125 controls the position of thefocus lens 104 using the focus detection result of each of on-imagingsurface phase difference AF and TV-AF.

Description of Focus Detection

The following describes focus detection in the digital camera usingsignals of the image sensor 122 in detail. On-imaging surface phasedifference AF and TV-AF are employed in the focus detection in theembodiment. Each of the AF schemes is described first.

(Description of on-Imaging Surface Phase Difference AF)

On-imaging surface phase difference AF is described first with referenceto FIGS. 2 to 4B. FIG. 2 is a diagram schematically showing a pixelarray in the image sensor 122 in the embodiment. FIG. 2 shows atwo-dimensional CMOS area sensor in the range of 6 rows arranged in thevertical direction (direction Y) and 8 columns arranged in thehorizontal direction (direction X), as seen from the lens unit 100 side.Color filters are put in a Bayer array. In pixels 211 of odd rows, greenand red color filters are alternately arranged from left. In pixels 211of even rows, blue and green color filters are alternately arranged fromleft. An on-chip microlens 211 i is formed on each color filter. Aplurality of rectangles inside the on-chip microlens 211 i arephotoelectric converters 211 a and 211 b.

In the embodiment, the photoelectric converter of every pixel is splitinto two areas in the direction X, and a photoelectric conversion signalin one of the split areas and a sum of photoelectric conversion signalsin the two areas can be read independently of each other. From theindependently read signals, the difference between the sum ofphotoelectric conversion signals in the two areas and the photoelectricconversion signal in one of the split areas is calculated as a signalcorresponding to a signal obtained in the other photoelectric conversionarea. Such photoelectric conversion signals in the split areas are usedas phase difference detection signals for phase difference AF by thebelow-mentioned method, and can also be used to generate a stereoscopic(3D) image made up of a plurality of images having parallax information.Meanwhile, the sum of photoelectric conversion signals in the two areasis used as a normal captured image.

FIG. 3 is a diagram schematically showing the structure of the imagesensor 122 including a read circuit in the embodiment. Reference numeral151 indicates a horizontal scanning circuit, and 153 indicates avertical scanning circuit. Vertical scan lines 152 a and 152 b andhorizontal scan lines 154 a and 154 b are arranged at the boundaries ofthe pixels, and signals are read out from the photoelectric converters211 a and 211 b via these scan lines.

The image sensor 122 in the embodiment can be driven in the followingtwo types of read modes that differ in resolution. The first read modeis all-pixel read mode which is a mode for capturing a high-resolutionstill image. The signals of all pixels are read in this case.

The second read mode is decimation read mode which is a mode forrecording a moving image or displaying only a preview image. Since thenumber of pixels necessary in this case is smaller than the number ofall pixels, signals are read only from pixels as a result of decimatingpixels by a predetermined ratio in both of the directions X and Y. Thedecimation read mode is equally used in the case where high-speedreading is required. In the case of decimation in the direction X,signals are added to improve the S/N. In the case of decimation in thedirection Y, signal outputs from rows to be decimated are ignored. Thefocus detection in the phase difference scheme and the contrast schemeis typically performed in the second read mode.

FIGS. 4A and 4B are diagrams for describing the conjugate relationbetween the exit pupil plane of the imaging optical system and thephotoelectric converters of the pixel 211 at an image height of 0, i.e.located around the center of the imaging plane, in the image capturingapparatus in the embodiment. The photoelectric converters 211 a and 211b of the pixel 211 in the image sensor 122 and the exit pupil plane ofthe imaging optical system are designed to be in the conjugate relationby the on-chip microlens 211 i. Typically, the exit pupil of the imagingoptical system substantially matches a plane on which an iris diaphragmfor adjusting the amount of light is placed. The imaging optical systemin the embodiment is a zoom lens having zoom function. Depending on thetype of the imaging optical system, the distance of the exit pupil fromthe imaging plane or the size of the exit pupil changes when a zoomoperation is performed. In the imaging optical system in FIGS. 4A and4B, the focal length is intermediate between the wide angle end and thetelephoto end, i.e. in the state of “middle”. Assuming this as astandard exit pupil distance Zep, eccentric parameters corresponding tothe image height (X, Y coordinates) and the shape of the on-chipmicrolens are designed optimally.

In FIG. 4A, a tube member 101 b holds the first lens group 101, and atube member 104 b holds the focus lens 104. The aperture-shutter 102 hasan aperture plate 102 a for defining the aperture diameter in a fullopen state, and an aperture blade 102 b for adjusting the aperturediameter during closing. The tube member 101 b, the aperture plate 102a, the aperture blade 102 b, and the tube member 104 b which function asthe member for limiting the light beam passing through the imagingoptical system show an optical virtual image as observed from theimaging plane. Moreover, a synthetic aperture near the aperture-shutter102 is defined as the exit pupil of the lens, and the distance from theimaging plane is defined as Zep as mentioned above.

Further, as shown in FIG. 4A, the pixel 211 is composed of the followingmembers from the lowest layer: the photoelectric converters 211 a and211 b; wiring layers 211 e to 211 g; a color filter 211 h; and theon-chip microlens 211 i. The two photoelectric converters 211 a and 211b are projected on the exit pupil plane of the imaging optical system bythe on-chip microlens 211 i. In other words, the exit pupil of theimaging optical system is projected on the surfaces of the photoelectricconverters 211 a and 211 b through the on-chip microlens 211 i.

FIG. 4B shows the projected images of the photoelectric converters 211 aand 211 b on the exit pupil plane of the imaging optical system. Theprojected images of the photoelectric converters 211 a and 211 b are EP1a and EP1 b, respectively. In the embodiment, the image sensor 122 canobtain the output of one of the two photoelectric converters 211 a and211 b and the output of the sum of the two photoelectric converters 211a and 211 b, as mentioned earlier. The output of the sum of the twophotoelectric converters 211 a and 211 b corresponds to the result ofphotoelectrically converting the light beam passing through both of theareas of the projected images EP1 a and EP1 b which occupy substantiallythe whole pupil area of the imaging optical system.

In FIG. 4A, the light beam is regulated by the aperture plate 102 a ofthe diaphragm as represented by the outermost part L of the light beampassing through the imaging optical system, and the projected images EP1a and EP1 b have substantially no vignetting due to the imaging opticalsystem. In FIG. 4B, the light beam in FIG. 4A is denoted by TL. Most ofthe projected images EP1 a and EP1 b of the photoelectric converters 211a and 211 b are contained within the light beam TL indicated by thecircle, which also demonstrates that substantially no vignetting occurs.Since the light beam is limited only by the aperture plate 102 a of thediaphragm, the light beam TL is substantially equal to the aperturediameter of the aperture plate 102 a. Here, the respective vignettingstates of the projected images EP1 a and EP1 b are symmetric withrespect to the optical axis in the center of the imaging plane, and thephotoelectric converters 211 a and 211 b receive the same amount oflight.

Thus, the microlens 211 i and the split photoelectric converters 211 aand 211 b pupil-split the light beam exited from the lens unit 100. Theresult of concatenating and organizing the outputs of the photoelectricconverters 211 a in a plurality of pixels 211 of a predetermined rangeon the same row is denoted as an AF image A, and the result ofconcatenating and organizing the outputs of the photoelectric converters211 b in the plurality of pixels 211 of the predetermined range on thesame row is denoted as an AF image B. As the signal of each of the AFimages A and B, a pseudo luminance (Y) signal calculated by adding theoutputs of green, red, blue, and green of the photoelectric converters211 a or 211 b in the Bayer array is used here. Alternatively, the AFimages A and B may be organized for each of the colors of red, blue, andgreen. By detecting the relative image deviation of such generated AFimages A and B by correlation computation, it is possible to detect thefocus deviation in the predetermined area, i.e. the defocus amount. Inthe embodiment, though one of the AF images A and B is not output fromthe image sensor 122, the sum of the images A and B is output asmentioned above and so the signal of the one of the AF images A and Bcan be obtained from the difference between the output of the sum andthe output of the other one of the AF images A and B.

As described above with reference to FIGS. 2 to 4B, the image sensor 122includes pixels that receive light beams passed through the exit pupilbeing split, so that phase difference AF can be performed using theobtained signals.

Although the above describes the structure of splitting the exit pupilin the horizontal direction, pixels for splitting the exit pupil in thevertical direction may also be provided in the image sensor 122. Theprovision of pixels for splitting the exit pupil in both directionsenables focus detection corresponding to the contrast of the subject innot only the horizontal direction but also the vertical direction.Further, although the above describes the case where two photoelectricconverters split each of all pixels, the three or more photoelectricconverters may split each pixel, and the photoelectric converters maysplit a part of the pixels if phase difference AF is only concerned.

(Description of TV-AF)

The following describes process flow of calculating various AFevaluation values for TV-AF. FIG. 5 is a block diagram mainly showingthe structure of the TV-AF focus detector 130.

When a signal read from the image sensor 122 is input to the TV-AF focusdetector 130, an AF evaluation signal processing circuit 401 extracts agreen (G) signal from a Bayer array signal, and performs a gammacorrection process of emphasizing low luminance components andsuppressing high luminance components. Although the embodiment describesthe case where a green (G) signal is used in TV-AF, all signals of red(R), blue (B), and green (G) may be used. Moreover, a luminance (Y)signal may be generated using all colors of RGB. Hence, the outputsignal generated by the AF evaluation signal processing circuit 401 ishereafter referred to as the luminance signal Y, regardless of whichcolor is used.

The following describes a method of calculating a Y peak evaluationvalue. The luminance signal Y gamma-corrected by the AF evaluationsignal processing circuit 401 is input to a line peak detection circuit402 for detecting a line peak value per horizontal line. The line peakdetection circuit 402 detects a Y line peak value per horizontal line ineach focus detection area set by an area setting circuit 413. The outputof the line peak detection circuit 402 is input to a vertical peakdetection circuit 405. The vertical peak detection circuit 405 performspeak hold in the vertical direction in each focus detection area set bythe area setting circuit 413, to generate a Y peak evaluation value. TheY peak evaluation value is effective for determination of a highluminance subject or a low illuminance subject.

The following describes a method of calculating a Y integral evaluationvalue. The luminance signal Y gamma-corrected by the AF evaluationsignal processing circuit 401 is input to a horizontal integrationcircuit 403 for detecting an integral value per horizontal line. Thehorizontal integration circuit 403 calculates the integral value of theluminance signal Y per horizontal line in each focus detection area setby the area setting circuit 413. The output of the horizontalintegration circuit 403 is input to a vertical integration circuit 406.The vertical integration circuit 406 performs integration in thevertical direction in each focus detection area set by the area settingcircuit 413, to generate a Y integral evaluation value. The Y integralevaluation value enables determination of the brightness of each focusdetection area as a whole.

The following describes a method of calculating a max-min evaluationvalue. The luminance signal Y gamma-corrected by the AF evaluationsignal processing circuit 401 is input to the line peak detectioncircuit 402, to detect the Y line peak value per horizontal line in eachfocus detection area. The gamma-corrected luminance signal Y is alsoinput to a line minimum value detection circuit 404. The line minimumvalue detection circuit 404 detects the minimum value of the luminancesignal Y per horizontal line in each focus detection area. The detectedline peak value and minimum value of the luminance signal Y perhorizontal line are input to a subtractor to calculate “(line peakvalue)−(minimum value)”, and then the result is input to a vertical peakdetection circuit 407. The vertical peak detection circuit 407 performspeak hold in the vertical direction in each focus detection area, togenerate a max-min evaluation value. The max-min evaluation value iseffective for determination of low contrast and high contrast.

The following describes a method of calculating an area peak evaluationvalue. The luminance signal Y gamma-corrected by the AF evaluationsignal processing circuit 401 is input to a BPF 408 to extract aspecific frequency component and generate a focus signal. The focussignal is input to a line peak detection circuit 409 for detecting aline peak value per horizontal line. The line peak detection circuit 409detects a line peak value per horizontal line in each focus detectionarea. The detected line peak value is subjected to peak hold in eachfocus detection area by a vertical peak detection circuit 411, togenerate an area peak evaluation value. The area peak evaluation valuechanges little even when the subject moves in each focus detection area,and so is effective in determining whether or not to shift from anin-focus state to a state for searching for an in-focus position again.

The following describes a method of calculating an all-line integralevaluation value. The line peak detection circuit 409 detects the linepeak value per horizontal line in each focus detection area, as in thecase of the area peak evaluation value. The line peak value is input toa vertical integration circuit 410, to perform integration for all thehorizontal scan lines in the vertical direction in each focus detectionarea to generate an all-line integral evaluation value. Thehigh-frequency all-line integral evaluation value has a wide dynamicrange and high sensitivity because of the effect of integration, and sois effective as a main evaluation value of TV-AF for detecting anin-focus position. In the embodiment, this all-line integral evaluationvalue that changes according to the defocus state and is used for focuscontrol is referred to as a focus evaluation value.

The area setting circuit 413 generates a gate signal for each focusdetection area for selecting a signal at a predetermined position in thescreen set by the camera MPU 125. The gate signal is input to each ofthe line peak detection circuit 402, the horizontal integration circuit403, the line minimum value detection circuit 404, the line peakdetection circuit 409, the vertical peak detection circuits 405, 407,and 411, and the vertical integration circuits 406 and 410. The timingat which the luminance signal Y is input to each circuit is controlledso that each evaluation value is generated for the luminance signal Y ineach focus detection area. The area setting circuit 413 can set aplurality of areas in accordance with each focus detection area.

An AF controller 151 in the camera MPU 125 receives each evaluationvalue obtained in the above-mentioned manner, and controls the focusactuator 113 via the focus drive circuit 116 to move the focus lens 104in the optical axis direction OA, thus executing AF control.

In the embodiment, each type of AF evaluation value is calculated notonly in the horizontal line direction but also in the vertical linedirection, as described above. This enables focus detection usingcontrast information of the subject in both the horizontal and verticaldirections.

In TV-AF, each type of AF evaluation value mentioned above is calculatedwhile driving the focus lens 104, and the focus lens positioncorresponding to the maximum all-line integral evaluation value isdetected to perform focus detection.

Description of Focus Detection Area

FIG. 6 is a diagram showing focus detection areas in an imaging range.On-imaging surface phase difference AF and TV-AF are performed in such afocus detection area based on a signal obtained from the image sensor122. In FIG. 6, the dotted rectangle represents an imaging range 217 ofthe image sensor 122. In the embodiment, the focus detection areas 218ah, 218 bh, and 218 ch for on-imaging surface phase difference AF in thehorizontal direction are set at a total of three locations, i.e. acenter part and right and left parts of the imaging range 217. Inaddition, focus detection areas 219 a, 219 b, and 219 c subjected toTV-AF are formed so as to respectively contain the three focus detectionareas 218 ah, 218 bh, and 218 ch for on-imaging surface phase differenceAF. In each focus detection area subjected to TV-AF, contrast detectionis performed using the focus evaluation values in the horizontal andvertical directions as described with reference to FIG. 5.

Although FIG. 6 shows an example where three focus detection areas areroughly provided, the present invention is not limited to three areas,and a plurality of areas may be provided at any positions. In the casewhere the photoelectric converters split a pixel in the direction Y, anarea in which pixels are arranged in the vertical direction may be setas the focus detection area for on-imaging surface phase difference AF.

Description of Focus Detection Process Flow

Next, focus detection (AF) process of the digital camera having theabove configuration according to the embodiment will be described withreference to FIGS. 7A and 7B. FIGS. 7A and 7B are flowcharts showing anAF processing procedure of the digital camera. The control programrelating to this processing is executed by the camera MPU 125. When theAF processing starts, the camera MPU 125 sets focus detection areas asshown in FIG. 6 for performing focus control on a subject in step S10,and performs focus detection either in the phase difference scheme or inthe contrast scheme. The focus detection result obtained here is denotedby DEF_B.

Next in step S11, BP (best focus point) correction information isobtained. BP correction information is information for correcting anerror of a focus position that occurs in accordance with each edgeangle. As this information differ between different lenses, it isobtained via the lens MPU 117 in response to a request of the camera MPU125. Alternatively, the camera 120 may store the BP correctioninformation in relation to the lens unit 100. FIG. 8 shows an example ofthe BP correction information stored in the lens memory 118. The lensmemory 118 stores in-focus point correction information f(θ)corresponding to the edge angle θ of a subject that can be obtained asdescribed below. The edge angle of the subject here is an angle of aslope of an edge of the subject with respect to the reference coordinateXY on a screen as shown in FIG. 9. The edge angle of a subject in a casewhere the subject is as shown by the hatching in FIG. 9 is θ, and thein-focus position correction information in that case is f(θ).

In a case where theoretical BP correction information of a designedstructure is stored, in-focus position correction information betweenθ=0° to 45° shown in FIG. 9 needs to be stored as the information, sincethe in-focus position correction information f(θ) are the same for focusdetection areas located at symmetric positions with respect to anoptical axis of an optical imaging system. Further, in a case where thecorrection value varies a little depending on the edge angle of asubject, the BP correction information may be stored as a common value.

In a case where the in-focus position correction information for thefocus detection result subjected to correction changes in accordancewith the zoom position and the focus lens position, it is desirable tostore the correction information as shown in FIG. 8 for each state ofthe zoom position and the focus lens position. Further, since thein-focus position correction information differ for different imageheights, it is desirable to store the correction information forpredetermined image heights.

Next, the edge angle/angles and the number of edge/edges of a subjectare obtained in step S12. Here, the angle of the slope of an edge withrespect to the coordinates XY in a screen is detected for each focusdetection area. In an example shown in FIG. 6, if DEF_B is obtained bythe on-imaging surface phase difference AF, the edge angle/angles andthe number of the edge/edges are obtained for each of the focusdetection areas 218 ah, 218 bh and 218 ch. If DEF_B is obtained by theTV-AF, the edge angle/angles and the number of edge/edges are obtainedfor each of the focus detection areas 219 a, 219 b and 219 c. Here, theedge detection is performed by applying edge filtering process or thelike, and detects edge angle/angles. An example of edge detectionprocess will be explained with reference to FIG. 10, although the edgedetection method is not limited thereto.

The direction of slope q(x, y) at each pixel position coordinates (x, y)is calculated using the following expression (1), for example.

θ(x,y)=tan⁻¹(V(x,y)/H(x,y))  (1)

The pixel position coordinates (x, y) are expressed in the rectangularcoordinate system with the light direction and the up direction beingpositive as shown in FIG. 9. Here, H(x, y) indicates a horizontalcontrast intensity of a specific frequency at the coordinates (x, y),and given by the following expression (2). Here, P(α, β) indicates aluminance value at a pixel position (α, β). FIG. 10 shows acorresponding diagram of respective coordinates when enlarged to a pixellevel.

H(x,y)=P(x+1,y)−P(x−1,y)  (2)

Similarly, V(x, y) indicates a vertical contrast intensity of a specificfrequency at the coordinates (x, y), and given by the followingexpression (3)

V(x,y)=P(x,y+1)−P(x,y−1)  (3)

Here, a detection filter used for calculating the contrast intensitiesof H(x, y) and V(x, y) is (1, 0, −1); however, the detection filter isnot limited to this, and a filter capable of detecting the frequencycomponents of a subject may be used instead.

Next, the edge angle/angles θ and the number of edge/edges n of asubject in each focus detection area are obtained from the slopedirection θ(x, y) at each pixel position coordinates (x, y). Here, theslope direction θ(x, y) is obtained for each pixel position coordinatesof each focus detection area, a histogram is generated for each focusdetection area, and the edge angle/angles θ and the number ofedges/edges n of the subject is obtained for each focus detection area.The method of this will be explained with reference to FIG. 11.

FIG. 11 is a histogram in which an ordinate shows a slope direction θand an abscissa shows the number of event, when the slope direction θ(x,y) is calculated at each pixel position coordinates (x, y) in a focusdetection area. If the subject as shown in FIG. 9 is shot in the focusdetection area, the histogram showing the frequency of occurrence is asshown in FIG. 11, and exhibits that the subject shown in FIG. 9 has anedge having an intensity in the slope direction θ=30°. At this time, itis expected that a certain number of detection errors occur due to anelectrical signal noise of the image sensor 122, blurriness of a subjectimage, and parallax of lenses. Accordingly, the slope direction havingthe frequency of occurrence not less than a detection number thresholdSH is determined as the edge angle θ of the subject in the focusdetection area. Namely, in the example of FIG. 11, θ=30° and n=1, sinceonly the slope direction θ having the number of occurrence not less thanthe detection number threshold SH is determined as the edge angle θ.

In step S13, it is determined whether or not the number of edge/edges nof the subject detected in step S12 is 1 or less (namely, 1 or 0). Ifthe number of edge/edges n is 1 or less, the process proceeds to stepS14, where the correction value BP1=0 is set. This is because if onlyone edge angle θ exists, the focus position is determined based on theedge regardless of the detection direction of focus detection system,and the BP correction in accordance with the edge angel is not needed.Further, when no edge is detected, the BP detection in accordance withthe edge angle cannot be performed, there is no need to perform BPcorrection.

On the other hand, in a case where it is determined that the number ofedge/edges n of the subject is plural in step S13, the process proceedsto step S15. In step S15, in-focus position correction information f(θ)for each of the plurality of edge angles θ is obtained from the BPcorrection information obtained in step S11. If two edges exist in thesubject as shown in FIGS. 12A and 12B and the edge angles θ are 45° and90°, the number of edges n of the subject=2, and the in-focus positioncorrection information to be obtained from in the BP correctioninformation shown in FIG. 8 is f(45) and f(90).

Next in step S16, the correction value BP1 is calculated by weighing thein-focus position correction information corresponding to the edgeangles θ of the subject obtained by the process of step S15.

Here, a calculation method of the correction value BP1 will be explainedwith reference to FIG. 7B. In step S20, an AF correction amount A iscalculated. in this step, among the plurality of edge angles θ of thesubject detected in step S12, an edge angle θX used in AF detection isselected, and the AF correction amount A=f(θX) is detected from a BPcorrection information table.

The edge angle θX may be stored for each line of AF detection.Alternatively, the edge angle θX may be an edge angle that may be usedin AF at high possibility. For example, in a case where a subject is asshown in FIG. 12A and the scan direction for AF detection is theascending direction of the x-axis, there is a high possibility thatfocus detection is performed on the basis of an edge having an angle (anangle closest to θ=90° in FIG. 12A) orthogonal to the ascendingdirection of the x-axis. In this case, θX=90° may be used.Alternatively, an edge angle θ of the subject at a position where thecontrast of the edge is high may be selected as θX. For example, if asubject shown in FIG. 12B exists in a focus detection area, the edgeangles of the subject detected in step S12 are θ=45° and 90°. Betweenthem, in the subject shown in FIG. 12B, the contrast of the subject ishigher at θ=45°, θX=45° may be selected. Further, θX may be determinedin accordance with the scanning direction at the time of AF detectionand edge contrast, or may be calculated by weighting in accordance withcontrast. For the contrast direction of the subject, the Max-Minevaluation value as described above may be suitably used. As describedabove, an edge angle with higher probability that may have been used inthe AF detection is detected on the basis of the predeterminedcondition.

Next in step S21, a detection area correction amount B is calculated. Instep S21, an average of in-focus position correction amounts f(θi) ateach edge angle θi that exists in an image is calculated on the basis ofa plurality of edge angles θ of a subject detected in step S12 and theBP correction information, and a detection area correction amount B isdetected. Given that the number of edges n detected in step S12 is k,then it is obtained with the following equation.

B=Σk f(θi)/k  (4)

This is based on a thought in which, if two edge angles of a subjectexist (θ=45° and 90°) as shown in FIGS. 12A and 12B, the in-focusposition of the subject that a human senses may be given by the averageof f(45) and f(90). At this time, if the contrast of the subject differsfor different edge angles as shown in FIG. 12B, the sensitivity forfocus detection may be higher at an edge having a higher contrast in thecaptured image. Accordingly, the in-focus position correction amountsf(θi) may be weighted to obtain a weighted average as in step S20.Further, if there is a main subject such as a face in the capturedimage, a higher weight may be put on the main subject.

In step S22, a difference between the detection area correction amount Bdetected in step S21 and the AF correction amount A detected in step S20is calculated to obtain the correction value BP1.

BP1=A−B  (5)

After calculating the correction value BP1, the process returns to FIG.7A. In step S17, the focus detection result DEF_B obtained in step S10is corrected using the calculated correction value BP1 in accordancewith the following expression (6), thereby a defocus amount DEF_A iscalculated.

DEF_(—) A=DEF_(—) B−BP1  (6)

Here, a method of detecting the edge angle/angles of a subject andcorrecting the in-focus position for each of the focus detection areasshown in FIG. 6 is described, however, the correction may be performedfor each AF detection line. In addition, a correction amount may becalculated from image signals corresponding to part of the focusdetection area in order to reduce a calculation load.

Next, in step S18, the focus lens 104 is moved on the basis of thecorrected defocus amount DEF_A that is calculated using the expression(6) (focus control). The process proceeds to step S19 where in-focusnotification is displayed on the display 126 for the focus detectionarea where the defocus amount used for driving the focus lens 104 iscalculated, and the AF processing is ended.

According to the embodiment as described above, a corrected position forAF is calculated by focusing on an edge angle/angles of a subject whenperforming focus detection. As a result, the correction value can becalculated in the same method regardless of an AF scheme.

While the present invention has been described with reference toexemplary embodiments, it is to be understood that the invention is notlimited to the disclosed exemplary embodiments. The scope of thefollowing claims is to be accorded the broadest interpretation so as toencompass all such modifications and equivalent structures andfunctions.

This application claims the benefit of Japanese Patent Application No.2014-139161, filed on Jul. 4, 2014, which is hereby incorporated byreference herein in its entirety.

What is claimed is:
 1. An image capturing apparatus comprising: an imagesensor configured to perform photoelectric conversion on light thatenters via an imaging optical system and output an image signal; a focusdetection unit configured to detect an in-focus position based on theimage signal output from the image sensor; an edge detection unitconfigured to detect an edge angle and a number of edge of a subjectincluded in an image based on the image signal output from the imagesensor; and a correction unit configured to obtain a correction amountfor the in-focus position based on the detected edge angle and thenumber of edge and correct the in-focus position detected by the focusdetection unit based on the obtained correction amount.
 2. The imagecapturing apparatus according to claim 1 further comprising a storageunit configured to store correction information indicative of aplurality of edge angles, and correction amounts for an in-focusposition corresponding to the plurality of edge angles, respectively,wherein the correction unit obtains the correction amount for thein-focus position based on a correction amount, stored in the storageunit, corresponding to the detected edge angle.
 3. The image capturingapparatus according to claim 2, further comprising a unit configured toobtain the correction information from the imaging optical system. 4.The image capturing apparatus according to claim 1, wherein in a casewhere the detected number of edges is plural, the correction unitaverages or weighted-averages the correction amounts for the in-focusposition corresponding to the plurality of detected edge angles, andperforms the correction based on the averaged correction amount.
 5. Theimage capturing apparatus according to claim 4, wherein the correctionunit selects an edge angle used for detecting the in-focus position inthe focus detection unit on the basis of a predetermined condition andobtains a correction amount corresponding to the selected edge angle,and performs the correction using a difference between the obtainedcorrection amount and the averaged correction amount.
 6. The imagecapturing apparatus according to claim 1, wherein the correction unitavoids performing the correction in a case where the number of detectededge is not plural.
 7. The image capturing apparatus according to claim1, wherein the focus detection unit detects the in-focus position usingpart of the image signal included in a preset focus detection area, andthe edge detection unit detects the edge angle and the number of edgebased on the image signal included in the focus detection area.
 8. Theimage capturing apparatus according to claim 1, wherein the focusdetection unit detects the in-focus position based on contrast of theimage signal.
 9. The image capturing apparatus according to claim 1,wherein the image sensor includes a plurality of microlenses, and eachof at least part of the microlenses is configured to correspond to aplurality of photoelectric conversion portions, and wherein the focusdetection unit detects the in-focus position based on a phase differencebetween a pair of image signals corresponding to the plurality ofphotoelectric conversion portions.
 10. A control method of an imagecapturing apparatus comprising: performing photoelectric conversion onlight that enters via an imaging optical system and outputting an imagesignal; detecting an in-focus position based on the output image signal;detecting an edge angle and a number of edge of a subject included in animage based on the output image signal; and obtaining a correctionamount for the in-focus position based on the detected edge angle andthe number of edge and correcting the in-focus position based on theobtained correction amount.